// pages/allotPro/allotPro1/allotPro1.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    placeBank: "",
    bankId: "",
    branchBankobj: {
      branchBankName: "",
      branchBankId: ""
    },
    corpType: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad (options) {
    // console.log(options, 'options')
    this.setData({
      corpType: options.corpType
    })
    if (options.corpType == '1') {
      wx.setNavigationBarTitle({
        title: '分配企业'
      })
    } else {
      wx.setNavigationBarTitle({
        title: '分配个体工商户'
      })
    }
    this.getinfo()
  },
  getinfo () {
    getApp().globalData.request(
      "/visit/show/admin_org", {},
      "POST"
    ).then(res => {
      console.log(res);
      this.setData({
        placeBank: res.data.bankName,
        bankId: res.data.bankId,
        ["branchBankobj.branchBankName"]: res.data.defaultBankName,
        ["branchBankobj.branchBankId"]: res.data.defaultBankId
      })
    })
  },
  toSelect () {
    wx.navigateTo({
      url: '../../../packageA/pages/zfBanktList/zfBanktList?parentId=' + this.data.bankId,
    })
  },
  confirmClick () {
    if (this.data.branchBankobj.branchBankName !== "" && this.data.branchBankobj.branchBankId !== "") {
      wx.navigateTo({
        url: `/pages/allotPro/allotPro2/allotPro2?placeBank=${this.data.placeBank}&branchBankName=${this.data.branchBankobj.branchBankName}&bankId=${this.data.branchBankobj.branchBankId}&corpType=${this.data.corpType}`,
      })
    } else {
      wx.showToast({
        title: '请先选择分支行！',
        icon: "none"
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow () {
    console.log(this.data.showName);
    this.setData({
      ["branchBankobj.branchBankName"]: this.data.showName,
      ["branchBankobj.branchBankId"]: this.data.bankId,
    })
    if (!this.data.showName) {
      this.getinfo()
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage () {

  }
})